package com.ghostbusters.fingertrack.control;

import com.ghostbusters.fingertrack.calibration.Calibration;
import com.ghostbusters.fingertrack.gui.MainFrame;
import com.ghostbusters.fingertrack.match.Matcher;

public class MatchControl<E> {
	
	private Matcher<E> matcher;
	private MainFrame mainFrame;

	private Calibration<E> calibration;
	
	public static void main(String[] args) throws Exception{
		
		// pretend this is a legit calibration
		Calibration<Character> calibration = new Calibration<Character>();
		
		MatchControl<Character> control = new MatchControl<Character>(null, calibration);
		
		//Begins match!
		control.startMatch();
		
		// End Match!
		control.endMatch();
		
		
		
		
	}
	
	public MatchControl(MainFrame mainFrame, Calibration<E> calibration) {
		setMainFrame(mainFrame);
		setCalibration(calibration);
	}
	
	public void startMatch() {
		
		if(calibration.getMap().keySet().size() == 0) {
			// bad!
			System.out.println("ERROR: Calibration does not have content so no use matching");
		}
		
		setMatcher(new Matcher<E>(getMainFrame(), getCalibration()));
		
	}
	
	public void endMatch() throws Exception {
		getMatcher().end();
	}

	public MainFrame getMainFrame() {
		return mainFrame;
	}

	public void setMainFrame(MainFrame mainFrame) {
		this.mainFrame = mainFrame;
	}

	public void setMatcher(Matcher<E> matcher) {
		this.matcher = matcher;
	}

	public Matcher<E> getMatcher() {
		return matcher;
	}

	public void setCalibration(Calibration<E> calibration) {
		this.calibration = calibration;
	}

	public Calibration<E> getCalibration() {
		return calibration;
	}

}
